package com.siao.example.libaray.display.view
{
	import com.siao.component.Canvas;
	import com.siao.display.Align;
	import com.siao.display.LayoutElement;
	import com.siao.example.common.ui.Layer;
	import com.siao.mvc.View;
	
	import flash.display.Sprite;
	
	/**
	 * 布局视图
	 * @author SiaoLeon
	 */
	public class DisplayLayoutView extends View
	{
		// -------------------------------------------------------------------------------------------------------- 静态常量
		
		// -------------------------------------------------------------------------------------------------------- 静态变量
		
		// -------------------------------------------------------------------------------------------------------- 静态方法
		
		// -------------------------------------------------------------------------------------------------------- 静态函数
		
		// -------------------------------------------------------------------------------------------------------- 属性
		
		// -------------------------------------------------------------------------------------------------------- 变量
		
		private var container:LayoutElement;
		
		private var menu:LayoutElement;
		
		private var list:LayoutElement;
		
		private var content:Canvas;
		
		// -------------------------------------------------------------------------------------------------------- 构造
		
		/**
		 * 构造函数
		 */
		public function DisplayLayoutView()
		{
			super();
		}
		
		// -------------------------------------------------------------------------------------------------------- 方法
		
		override public function onAdd():void
		{
			this.container = new LayoutElement();
			this.container.marginTop = 80;
			this.container.padding = 10;
			this.container.draw(0X000000, 0.2);
			Layer.instance.content.addChild(this.container);
			
			this.menu = new LayoutElement();
			this.menu.draw(0XFF0000, 0.2);
			this.menu.alignV = Align.BOTTOM;
			this.menu.height = 80;
			this.container.addChild(this.menu);
			
			this.list = new LayoutElement();
			this.list.draw(0X00FF00, 0.2);
			this.list.alignH = Align.LEFT;
			this.list.width = 200;
			this.list.marginBottom = 80;
			this.container.addChild(this.list);
			
			this.content = new Canvas(500, 300);
			this.content.draw(0X0000FF, 0.2);
			this.content.alignH = Align.RIGHT;
			this.content.alignV = Align.TOP;
			this.content.marginRight = 20;
			this.content.marginBottom = 20;
			this.container.addChild(this.content);
			
			var sprite:Sprite = new Sprite();
			sprite.graphics.beginFill(0X0F0F0F, 0.3);
			sprite.graphics.drawRect(0, 0, 300, 300);
			sprite.graphics.endFill();
			this.content.addChild(sprite);
			
			var test:LayoutElement = new LayoutElement();
			test.draw(0XFF00FF, 0.4);
			test.width = test.height = 30;
			test.alignH = Align.RIGHT;
			test.alignV = Align.BOTTOM;
			sprite.addChild(test);
		}
		
		override public function onRemove():void
		{
			this.container.remove();
			this.menu.remove();
			this.list.remove();
			this.content.clear();
			this.content.remove();
		}
	
		// -------------------------------------------------------------------------------------------------------- 函数
	
	}
}
